import { List } from 'immutable';
import Document from './document';
import Block from './block';

function create(attrs = {}) {
  const { object } = attrs;
  switch (object) {
    case 'block':
      return Block.create(attrs);
    case 'document':
      return Document.create(attrs);
    default:
      console.warn(`unsupport object type ${object}`);
  }
}
function createList(list) {
  if (List.isList(list) || Array.isArray(list)) {
    return List(list.map(create));
  }
}
export { create, createList };
